<?php 
namespace app\index\controller;
use think\Controller;
class Owner extends Controller{
	public function index(){
		return $this->fetch();
	}

	public function owner_ask(){
		foreach(model('Village')->where(['pid'=>'1'])->select() as $val){
			$data_area[] = $val->toArray();
		}
		// dump($data_area);
		$this->assign('data_area',$data_area);
		return $this->fetch();
	}

	public function do_ask(){
		// $res = model('Owner')->validate('Owner')->allowfield(true)->save(input('post.'));
		$vld = $this->validate(input('post.'),'Owner');
		if($vld !== true){
			$this->error($vld);
		}
		if(session('nickname') == null){
			$this->error('请先登录账号');
		}
		$where = [
			'nickname'=>session('nickname')
		];
		$oname = model('Vip')->where($where)->find()->vname;
		if($oname != ''){
			$_POST['oname'] = $oname;
		}else{
			$this->error('请先实名认证');
		}
		$tel = model('Vip')->where($where)->find()->tel;
		$_POST['tel'] = $tel;
		$_POST['otime'] = date('Y-m-d H:i:s',time());
		$res = model('Owner')->allowfield(true)->save($_POST);
		if($res > 0){
			$this->success('提交成功');			
		}else{
			$this->error(model('Owner')->getError());
		}
	}

}


 ?>